Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5021

Double JOIN is created for NOT IN when IN-list that the values all non-nullable is converted to Values

    XMLWordPrintableJSON

Details

    Description

      Double JOIN is created for NOT IN when IN-list that the values all non-nullable is converted to Values. 

      For example:

      select * from "scott".emp where (empno, deptno) not in ((7369, 20), (7499, 30));

      Before fix(Double Join):

      EnumerableCalc(expr#0..14=[{inputs}], expr#15=[0:BIGINT], expr#16=[=($t8, $t15)], expr#17=[IS NULL($t14)], expr#18=[>=($t9, $t8)], expr#19=[IS NOT NULL($t11)], expr#20=[AND($t17, $t18, $t19)], expr#21=[OR($t16, $t20)], proj#0..7=[{exprs}], $condition=[$t21])
        EnumerableMergeJoin(condition=[AND(=($10, $12), =($11, $13))], joinType=[left])
          EnumerableSort(sort0=[$10], sort1=[$11], dir0=[ASC], dir1=[ASC])
            EnumerableCalc(expr#0..9=[{inputs}], proj#0..9=[{exprs}], EMPNO0=[$t0], DEPTNO0=[/$t7])
              EnumerableNestedLoopJoin(condition=[true], joinType=[inner])
                EnumerableTableScan(table=[[scott, EMP]])
                EnumerableAggregate(group=[{}], agg#0=[COUNT()], agg#1=[COUNT($1)])
                  EnumerableValues(tuples=[[{ 7369, 20 }, { 7499, 30 }]])
          EnumerableSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC])
            EnumerableCalc(expr#0..1=[{inputs}], expr#2=[true], proj#0..2=[{exprs}])
              EnumerableValues(tuples=[[{ 7369, 20 }, { 7499, 30 }]])

      After Fix:

      EnumerableCalc(expr#0..12=[{inputs}], expr#13=[IS NOT TRUE($t12)], expr#14=[IS NULL($t9)], expr#15=[OR($t13, $t14)], proj#0..7=[{exprs}], $condition=[$t15])
        EnumerableMergeJoin(condition=[AND(=($8, $10), =($9, $11))], joinType=[left])
          EnumerableSort(sort0=[$8], sort1=[$9], dir0=[ASC], dir1=[ASC])
            EnumerableCalc(expr#0..7=[{inputs}], proj#0..7=[{exprs}], EMPNO0=[$t0], DEPTNO0=[$t7])
              EnumerableTableScan(table=[[scott, EMP]])
          EnumerableSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC])
            EnumerableCalc(expr#0..1=[{inputs}], expr#2=[true], proj#0..2=[{exprs}])
              EnumerableValues(tuples=[[{ 7369, 20 }, { 7499, 30 }]])

      Attachments

        Issue Links

          Activity

            People

              nobigo xiong duan
              nobigo xiong duan
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m